package com.verlet.nacos.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/nacos")
@RefreshScope
public class NacosController {

    @Value("${spring.application.name:nacos}")
    private String applicationName;

    /**
     * 其中$表示获取配置参数,#表示SpEL表达式
     */
    @Value("${project.org:alibaba}")
    private String name;
    @Value("${version:v0}")
    private String version;

    @RequestMapping("/getApplicationName")
    public String getApplicationName() {
        return applicationName;
    }

    @RequestMapping("/getConfig")
    public String getConfig() {
        return "name=" + name + ",version=" + version;
    }
}
